package com.ruoyi.xiche.controller;

import com.ruoyi.xiche.domain.ServiceItem;
import com.ruoyi.xiche.domain.Store;
import com.ruoyi.xiche.domain.StoreWithRating;
import com.ruoyi.xiche.service.ServiceItemService;
import com.ruoyi.xiche.service.StoreService;
import com.ruoyi.xiche.service.impl.StoreServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/store")
public class StoreController {

    @Autowired
    private StoreService storeService;

    //获取所有门店信息
    @GetMapping("/getStore")
    public List<Store> getStore() {
        return storeService.list();
    }

    //根据前端点击获取对应的门店信息
    @GetMapping("/getStoreById")
    public Store getStoreById(int id) {
        return storeService.getById(id);
    }

    public StoreController(StoreService storeService) {
        this.storeService = storeService;
    }

    @GetMapping("/ratings")
    public List<Map<String, Object>> getStoreRatings() {
        return storeService.getStoreRatings();
    }

    @GetMapping("/info")
    public List<StoreWithRating> getStoreInfoByStoreId(Long storeId) {
        return storeService.getStoreInfoByStoreId(storeId);
    }
}
